package com.xbongbong.pro.enums.businessrule.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/9/26 10:33
 * @since v1.0
 */
@Getter
public enum RuleOperatorFieldEnum {

    /**
     * 适合业务规则的字段
     */
    TEXT(FieldTypeEnum.TEXT),

    COMBO(FieldTypeEnum.COMBO),

    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),

    TEXTAREA(FieldTypeEnum.TEXTAREA),

    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),

    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),

    NUM(FieldTypeEnum.NUM),

    IMAGE(FieldTypeEnum.IMAGE),

    DATETIME(FieldTypeEnum.DATETIME),

    ADDRESS(FieldTypeEnum.ADDRESS),

//    LOCATION(FieldTypeEnum.LOCATION),

    USER(FieldTypeEnum.USER),

    USER_GROUP(FieldTypeEnum.USER_GROUP),

    DEPT(FieldTypeEnum.DEPT),

    // deptgroup 部门多选
    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP),

    SUB_FORM(FieldTypeEnum.SUB_FORM),

//    SERIAL_NO(FieldTypeEnum.SERIALNO),

    LINK_DATA(FieldTypeEnum.LINK_DATA),

    LINK_DATA_MULTI(FieldTypeEnum.LINK_DATA_MULTI),
    ;

    private FieldTypeEnum fieldTypeEnum;

    RuleOperatorFieldEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }

    public static RuleOperatorFieldEnum getByCode(Integer fieldType) {
        for (RuleOperatorFieldEnum ruleConditionFieldEnum : values()) {
            if (Objects.equals(ruleConditionFieldEnum.getFieldTypeEnum().getType(), fieldType)) {
                return ruleConditionFieldEnum;
            }
        }
        return null;
    }
}
